package com.goodomen.garbage.score.service.system;

import com.goodomen.garbage.common.persistence.mapper.system.SysPermissionMapper;
import com.goodomen.garbage.common.persistence.model.system.SysPermission;
import com.goodomen.garbage.score.constant.CacheKeyEnum;
import com.goodomen.garbage.score.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 功能权限 Service
 *
 * @author : Zhao Da
 * @since : 2019/4/28 17:17
 */
@Service
@Slf4j
public class SysPermissionService {

    @Resource
    private SysPermissionMapper sysPermissionMapper;
    @Autowired
    private RedisUtil redisUtil;

    public Map<String, List<SysPermission>> findPermissionMap() {
        LinkedHashMap<String, List<SysPermission>> map = new LinkedHashMap<>();
        List<String> tagList = sysPermissionMapper.findTagList();
        for (String tag : tagList) {
            List<SysPermission> permissionList = sysPermissionMapper.findByTagName(tag);
            map.put(tag, permissionList);
        }
        return map;
    }
}
